<%--
  Created by IntelliJ IDEA.
  User: 123
  Date: 2020/11/12
  Time: 14:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<select id="12">
    <option value="0">请选择科目</option>
    <option value="1">JSP</option>
    <option value="2">OOP</option>
    <option value="3">Javascript</option>
</select>
<button type="button" onclick="doAjax()">查询</button>
<table border="2px" id="s">
        <tr>
            <td>题干</td>
            <td>A.选项</td>
            <td>B.选项</td>
            <td>C.选项</td>
            <td>D.选项</td>
            <td>答案</td>
        </tr>
</table>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.11.1.js"></script>
<script type="text/javascript">
    doAjax(0)
    function doAjax() {
        var d=$("#12").val();
        console.log(d)
        $.ajax({
            url:"${pageContext.request.contextPath}/student_show",
            data:"c="+d,
            dataType:"json",
            type:"post",
            success:function (data) {
                $("tr:gt(0)").remove();
                for (var c=0;c<data.length;c++){
                    $("#s").append("<tr><td>"+data[c].question+"</td>\n" +
                        "            <td>"+data[c].optionA+"</td>\n" +
                        "            <td>"+data[c].optionB+"</td>\n" +
                        "            <td>"+data[c].optionC+"</td>\n" +
                        "            <td>"+data[c].optionD+"</td>\n" +
                        "            <td>"+data[c].answer+"</td></tr>")
                }
            }
        })
    }

</script>
</body>
</html>
